//
//  NewsflashRecommend.m
//  AutoHome
//
//  Created by wqh on 15-5-10.
//  Copyright (c) 2015年 Wqh. All rights reserved.
//

#import "NewsflashRecommend.h"

#import "NewsflashFilterView.h"
#import "NewsflashRecommendCell.h"
#import "RecommendModel.h"

#import "RecommendNormalDetail.h"
#import "NewsflashRecommendDetail.h"
#define kNewsflashRecommendCellId @"NewsflashRecommendCellId"

@interface NewsflashRecommend ()
@property (nonatomic) UIView *filterHeaderView;
@end

@implementation NewsflashRecommend

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
//    [self createFileterHeaderView];
    [self createTableView];
    [self downloadData];
}

- (void)createFileterHeaderView {
    self.filterHeaderView = [[[NSBundle mainBundle] loadNibNamed:@"NewsflashFilterView" owner:self options:nil] lastObject];
    self.filterHeaderView.frame = CGRectMake(0, 0, kScreenWidth, 44);
    [self.view addSubview:self.filterHeaderView];
}

- (void)createTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-64-49) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerNib:[UINib nibWithNibName:@"NewsflashRecommendCell" bundle:nil] forCellReuseIdentifier:kNewsflashRecommendCellId];
    [self.view addSubview:self.tableView];
    self.tableView.backgroundColor = [UIColor clearColor];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NewsflashRecommendCell *cell = [tableView dequeueReusableCellWithIdentifier:kNewsflashRecommendCellId forIndexPath:indexPath ];
    [cell showDataWithModel:self.dataArr[indexPath.row]];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 248;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NewsflashRecommendDetail *vc = [NewsflashRecommendDetail new];
    RecommendModel *model = self.dataArr[indexPath.row];
    
    vc.model = model;
    
    if (self.myPageJumpBlcok) {
        self.myPageJumpBlcok(vc);
    }
    if(self.myHiddeTabBarBlock) {
        self.myHiddeTabBarBlock(YES);
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
